
const state = {
    current: {},
    token: '',
    currentTime:"_"+new Date(Date.now()).getFullYear(),
    isCollapseMenu: false,
    showTagViews: true,
    needRestPwd: false,
}
const actions = {
    _setCurrentUserInfo ({commit}, user) {
        commit('@user/current', user)
    },
    _setMenuCollapse ({commit}, isCollapseMenu) {
        commit('@user/isCollapseMenu', isCollapseMenu)
    },
    _setShowTagViews ({commit}, showTagViews) {
        commit('@user/showTagViews', showTagViews)
    },
    _setToken ({commit}, token) {
        commit('@user/token', token)
    },
    _setNeedRestPwd ({commit}, needRestPwd) {
        commit('@user/needRestPwd', needRestPwd)
    },
    _setCurrentTime({commit}, currentTime){
        commit('@user/current',currentTime)
    },
    _logout ({commit}) {
        commit('@user/token', '')
        commit('@user/current', {})
        commit('@menu/setMenu', [])
        commit('@menu/setPermission', [])
        window.location = '#/login'
        window.location.reload()
    },
}
const mutations = {

    '@user/current' (state, data) {
        state.current = data
    },
    '@user/isCollapseMenu' (state, data) {
        state.isCollapseMenu = data
    },
    '@user/showTagViews' (state, data) {
        state.showTagViews = data
    },
    '@user/token' (state, token) {
        state.token = token
    },
    '@user/needRestPwd' (state, needRestPwd) {
        state.needRestPwd = needRestPwd
    },
    '@user/currentTime'(state,currentTime){
        state.currentTime = currentTime
    }
}

export default {
    state,
    mutations,
    actions,
}
